package com.dave.gd.service.impl;

import java.sql.Timestamp;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dave.gd.config.sysmgr.SysmgrConstants;
import com.dave.gd.service.IRolePermissionService;
import com.dave.gd.sysmgr.domain.entity.RolePermission;
import com.dave.gd.sysmgr.domain.mapper.RolePermissionMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class RolePermissionService implements IRolePermissionService {
    @Resource
    private RolePermissionMapper rolePerDao;
    
    @Override
    public int insert(RolePermission t) {
        Date date = new Date();
        Timestamp ttmp = new Timestamp(date.getTime());
        t.setCreatetime(ttmp);
        t.setUptime(ttmp);
        t.setState(SysmgrConstants.YES_STATE);
        
        return this.rolePerDao.insert(t);
    }
    
    @Override
    public int delete(long id) {
        return this.rolePerDao.deleteById(id);
    }
    
    @Override
    public int update(RolePermission t) {
        Date date = new Date();
        Timestamp ttmp = new Timestamp(date.getTime());
        t.setUptime(ttmp);
        
        return this.rolePerDao.update(t);
    }
    
    @Override
    public RolePermission get(long id) {
        return this.rolePerDao.queryById(id);
    }
    
    @Override
    public Page<RolePermission> queryPage(Integer pageNum, Integer pageSize, RolePermission t) {
       PageHelper.startPage(pageNum, pageSize);
       Page<RolePermission> prp = this.rolePerDao.queryPage(t);
       
       
        return prp;
    }
    
}
